package utils;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 *日期转字符串
 * @author Freedy
 * @date 2020/12/20 16:18
 */
public class DateUtils {
    public static String date2string(Date date, String patt) throws Exception{
        SimpleDateFormat sdf=new SimpleDateFormat(patt);
        String format = sdf.format(date);
        return format;
    }

    public static Date string2date(String str,String patt) throws Exception{
        SimpleDateFormat sdf=new SimpleDateFormat(patt);
        Date parse = sdf.parse(str);
        return parse;
    }
}
